﻿using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Windows.Forms;

namespace FIS.iDET
{
    public class GlobalConstants
    {
        // Version
        public const string stringVersion = "FIS Data Entry Support Tool\nVersion 2.0.0 Pre-Final";
        public const bool IsTri = false;
        public static DateTime ExpDate = new DateTime(2013, 2, 28);

        
        /* VARIABLES */
        // auto-jump tool-tip

        public const int offsetX = 40;
        public const int offsetY = 40;
        //  data for Page Compare Tool
        public const int maxPagesCompare = 260;
        public const int ExtendColumn = 1;
        public const string ExtendColumnName = "Page";
        
        // zoom
        public const int maxZoomFactor = 2;
        public const double minZoomFactor = 0.2;
        public const int maxZoomIndex = 10; // base 1 counter

        // data format style for data columns
        public static int ComboBoxDateFormatIndex;

        public static int ComboBoxZoomIndex=4;
        
        // username
        public static string Username = "No Name";

        // data columns info
        public static List<DoubleRectangle> ColumnsOriginalRects;
        public static List<DataColumn> Columns;
        public static List<int> DateColumnIndices;

        // xml template
        public static string TemplateName = "Untitled template";
        public static string TemplateVersion = "2.0.5";
        public static double TemplateZoom = 1;
        public static int TemplatePageCol = 0;

        // max Excel Range
        public const int maxRows = 2000; // In real: 65536
        public const int maxColumns = 100; // In real: 256

        public static void OptionInit()
        {
            // get user name
            Username = RegistryService.GetValue(REGISTRY_USER_NAME) == null ? "No Name" : RegistryService.GetValue(REGISTRY_USER_NAME).Trim();

            // date format index
            ComboBoxDateFormatIndex = Convert.ToInt32(RegistryService.GetValue(REGISTRY_DATE_FORMAT_INDEX));  // return 0 in case have no data.
            
            // exception handlde
            if (ComboBoxDateFormatIndex < 0) ComboBoxDateFormatIndex = 0;
            
            // zoom index
            ComboBoxZoomIndex = 4;

            // Pos Spin
            
        }

        public static bool IsDateColumn(int i)
        {
            return DateColumnIndices.IndexOf(i) > -1;
        }

        /*** CONSTANTS ***/
        // secret key used to generate serial number from machine ID
        public const string SERIAL_SECRET_KEY = "aed45dba1f73080de226c193d3f9d605";

        // Company name, mainly used for folder naming
        public const string COMPANY_NAME = "FPT BPO iDET";

        /* excel app */
        // excel auto save file name and location
        public const string AUTOSAVE_FILENAME = "autosave.xls";

        /* registry */
        // Default path of registry to store serial number
        public const string REGISTRY_PATH = "Software\\" + COMPANY_NAME;
        // serial number string name
        public const string REGISTRY_SERIAL_NUMBER_KEY = "Serial";
        // last working image file string name
        public const string REGISTRY_LAST_IMAGE_KEY = "Image";
        // last working image value for no file
        public const string REGISTRY_LAST_IMAGE_NULL_VALUE = "No image loaded";
        // last working excel file string name
        public const string REGISTRY_LAST_EXCEL_KEY = "Excel";
        // last working excel value for no file
        public const string REGISTRY_LAST_EXCEL_NULL_VALUE = "File has not been saved";
        // comboBox Date Format Index
        public const string REGISTRY_DATE_FORMAT_INDEX = "DateFormat";
        // user name
        public const string REGISTRY_USER_NAME = "UN";
        // no user name
        public const string REGISTRY_USER_NAME_NO_NAME = "No name";
    }
}
